Provide More Intuitive Behaviour for Launchd Services #40
Provide More Intuitive Behaviour for Launchd Services #40chipsenkbeil merged 3 commits intochipsenkbeil:mainfrom
Conversation
For the `OnSuccess` case, the logic was actually inverted, so the service was restarting when the exit was *not* successful. This has now been corrected. The logic we were previously using for the `OnSuccess` case has now been applied to the `OnFailure` case, so we now support that scenario rather than emitting a warning saying we don't support it. A comment clarifies that when the `SuccessfulExit` construct is *not* used, this is effectively the `Always` policy.
|
Hi Chip, I realise this is another breaking change quite soon, but I really think it's worth it. Due to the addition of the A little bug was also fixed. It looks like I have some breaking tests here. Will try to investigate. |
When the service definition includes the `KeepAlive` setting it causes services to automatically start when `launchctl load` is used. This is quite unintuitive and is not how services behave on other platforms. We now make use of the `Disabled` setting to prevent the service starting automatically and make it behave like service managers on other platforms. This is desirable when you want to add many services first and not have them all start at the same time, which is the case for our application. It also seems to be the behaviour most of our users expect and I personally think makes most sense.
4f353e1 to
5344091
Compare
|
I've now fixed the failing test case. The Launchd test for running as sudo but with a specific user is still broken. Unfortunately I still don't have time to look into this at the moment, but do intend to when I get some free time. |
5344091 to
652d31a
Compare
b6fda30 fix: use correct logic for launchd restart policies
For the
OnSuccesscase, the logic was actually inverted, so the service was restarting when theexit was not successful. This has now been corrected.
The logic we were previously using for the
OnSuccesscase has now been applied to theOnFailurecase, so we now support that scenario rather than emitting a warning saying we don't support it.
A comment clarifies that when the
SuccessfulExitconstruct is not used, this is effectively theAlwayspolicy.da5d943 feat: prevent launchd services starting when keepalive is used
When the service definition includes the
KeepAlivesetting it causes services to automaticallystart when
launchctl loadis used. This is quite unintuitive and is not how services behave onother platforms.
We now make use of the
Disabledsetting to prevent the service starting automatically and make itbehave like service managers on other platforms. This is desirable when you want to add many
services first and not have them all start at the same time, which is the case for our application.
It also seems to be the behaviour most of our users expect and I personally think makes most sense.
652d31a chore(release): bump to version 0.10.0